package cn.t.keycloak.demo.custom.impl;

import cn.t.keycloak.demo.custom.ICustomSpiProvider;
import cn.t.keycloak.demo.custom.ICustomSpiProviderFactory;
import lombok.extern.slf4j.Slf4j;
import org.keycloak.Config;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;

/**
 * 同理，提供一个工厂
 * @author 陶敏麒
 * @date 2023/11/7 14:10
 */
@Slf4j
public class CustomSpiImplProviderFactory implements ICustomSpiProviderFactory {

    private static final String ID = "custom-spi-provider";

    @Override
    public ICustomSpiProvider create(KeycloakSession keycloakSession) {
        // 生产一个自定义的provider
        return new CustomSpiImplProvider(keycloakSession);
    }

    @Override
    public void init(Config.Scope scope) {
        log.info("CustomSpiImplProviderFactory开始初始化");
    }

    @Override
    public void postInit(KeycloakSessionFactory keycloakSessionFactory) {

    }

    @Override
    public void close() {

    }

    @Override
    public String getId() {
        return ID;
    }
}
